package com.yf.domain.security;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.ibatis.type.JdbcType;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Set;


/**
 * @author chentianwei
 * @date 2023/4/17 10:56
 * @description User domain
 */
@Getter
@Setter
@ToString
@TableName(value = "sys_user")
@EqualsAndHashCode(callSuper = false)
public class User implements Serializable {

    @TableId(type = IdType.AUTO,value = "user_id")
    @Schema(name = "主键",hidden = true)
    private Long id;

    @TableField(value = "user_name")
    @Schema(name = "用户名")
    private String userName;

    @TableField(value = "dept_id")
    @Schema(name = "部门ID")
    private Long deptId;

    @TableField(exist = false)
    private Set<Role> roles;

    @TableField(exist = false)
    private Department department;

    @TableField(exist = false)
    @Schema(name = "用户岗位",hidden = true)
    private Set<Job> jobs;

    @TableField(value = "password")
    @Schema(name = "密码")
    private String password;

    @TableField(value = "nick_name")
    @Schema(name = "昵称")
    private String nickName;

    @TableField(value = "gender")
    @Schema(name = "性别")
    private String gender;

    @TableField(value = "phone")
    @Schema(name = "phone")
    private String phone;

    @TableField(value = "is_enable",jdbcType = JdbcType.BOOLEAN)
    @Schema(name = "是否启用 状态:1启用,0禁用")
    private Boolean isEnable;

    @TableField(value = "email")
    @Schema(name = "电子邮箱")
    private String email;

    @TableField(value = "is_admin",jdbcType = JdbcType.BOOLEAN)
    @Schema(name = "是否为admin账号",hidden = true)
    private Boolean isAdmin = false;

    @TableField(value = "pwd_reset_time")
    @Schema(name = "最后修改密码的时间",hidden = true)
    private Date pwdResetTime;

    @TableField(value = "remark")
    @Schema(name = "备注信息")
    private String remark;

    @TableField(value = "create_time",insertStrategy = FieldStrategy.DEFAULT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    private Timestamp createTime;

    @TableField(value = "update_time",updateStrategy = FieldStrategy.ALWAYS)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    private Timestamp updateTime;

    @TableField(value = "create_by",insertStrategy = FieldStrategy.DEFAULT)
    private String createBy;

    @TableField(value = "update_by",updateStrategy = FieldStrategy.ALWAYS)
    private String updateBy;
}
